< previous page page_600 next page >

Page 600
9f31265bb40b592b1929e18a47ab28e5.gif
   'With oReg
   '   txtKeyValue = .KeyGet(txtSection, _
                           txtKeyName, _
                           "")
   'End With

   Set oReg = Nothing
End Sub
Notice that at the end of this routine I have commented out an alternate way to get databy passing all the relevant information directly to the KeyGet() method.
This code should look very familiar to youits exactly the same as the code in the INI example, except for the name of the class.
The KeyGet() Method of the Registry Class
The KeyGet() method in the Registry class accepts optional arguments for the section name, the key name, and the default value (in case you dont find the value youre after). Notice that each of the optional arguments has a default value. You can check each of the arguments against their default values to see whether any have been passed into the method. If any have been passed in, you need to override the module-level variable that corresponds to the argument. After all the module-level variables are set, you then call the GetSetting() method to return the data value back to the mstrKeyValue variable. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Public Function KeyGet( _
               Optional strSection As String = "NA", _
               Optional strKeyName As String = "NA", _
               Optional strDefault As String = "") _
               As String

   ' Fill in properties
   If strSection <> "NA" Then
      mstrSection = strSection
   End If
   If strKeyName <> "NA" Then
      mstrKeyName = strKeyName
   End If
   mstrDefault = strDefault

 
< previous page page_600 next page >

If you like this book, buy it!